import { Injectable } from '@nestjs/common';
import { Cat } from './cat.interface';

/**
 * @Injectable() 装饰器附加元数据，该元数据声明 CatsService 是可由 Nest IoC 容器管理的类。
 */
@Injectable()
export class CatsService {
  private readonly cats: Cat[] = [];
  create(cat: Cat) {
    this.cats.push(cat);
  }

  findAll(): Cat[] {
    return this.cats;
  }
  findOne(id: number) {
    return {
      id: id,
      name: `cat #${id}`,
    };
  }
}
